{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "c5252b0b-2142-4cc0-af3b-d610e46dc889",
   "metadata": {},
   "outputs": [
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "请输入球的半径： 1\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "球为表面积为：12.57，体积为：4.19\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "r = float(input(\"请输入球的半径：\")) #输入球的半径并转换为浮点数\n",
    "area = 4 * math.pi * r ** 2\n",
    "volume = 4*math.pi*r ** 3/3\n",
    "print(str.format(\"球为表面积为：{0:2.2f}，体积为：{1:2.2f}\", area, volume))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f2a4752b-8fee-474f-9f53-94d2df492025",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
